package cn.chinaunicom.smart.community.generator.runner;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 *
 * @ProjectName:    gateway-web
 * @Package:        com.springboot.cloud.gateway.runner
 * @ClassName:      StartedUpRunner
 * @Description:    启动运行
 * @Author:         wangjc
 * @CreateDate:     2020/3/28 0028 13:42
 * @UpdateUser:     更新者
 * @UpdateDate:     2020/3/28 0028 13:42
 * @UpdateRemark:   更新内容
 * @Version:        1.0
 */
@Slf4j
@Component
public class StartedUpRunner implements ApplicationRunner {

    @Autowired
    private ConfigurableApplicationContext context;

    @Value("${spring.application.name:'generator-server'}")
    private String applicationName;

    @Override
    public void run(ApplicationArguments args) {
        if (context.isActive()) {
            log.info("  _   _   _   _   _   _   _   _");
            log.info(" / \\ / \\ / \\ / \\ / \\ / \\ / \\ / \\");
            log.info("( c | o | m | p | l | e | t | e )");
            log.info(" \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/");
            log.info("{} 启动完毕，时间：{}", applicationName, LocalDateTime.now());
        }
    }
}
